<!DOCTYPE HTML>
<html>
<head th:include="fragments/_header :: _head('资源列表')"></head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 资源列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray">
		<span class="l">
			<a href="javascript:;" onclick="add('添加资源','/resources/add','700','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加资源</a>
            <a th:if="${level>1}" th:href="@{/resources/list(pid=${pLevel})}" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe67d;</i> 返回上一级</a>
		</span>
    </div>
    <div class="text-c mt-20">
        <form action="/resources/list" id="searchForm">
            <input type="hidden" name="pid" id="pid" th:value="${pid}" value="0">
        </form>
    </div>
    <div class="dataTables_wrapper no-footer  mt-20">
        <table class="table table-border table-bordered table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="7">资源列表</th>
            </tr>
            <tr class="text-c">
                <th width="150">资源名</th>
                <th width="100">编码</th>
                <th width="130">类型</th>
                <th width="200">链接</th>
                <th width="30">排序</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c"  th:each="resources:${list}">
                <td th:if="${level<4}">
                    <a th:text="${resources.name}" th:href="@{/resources/list(pid=${resources.id})}">资源名</a>
                </td>
                <td th:if="${level>3}" th:text="${resources.name}">资源名</td>
                <td th:text="${resources.code}">编码</td>
                <td th:text="${resources.type}">类型</td>
                <td th:text="${resources.url}">链接</td>
                <td th:text="${resources.sort}">排序</td>
                <td class="td-manage">
                    <a style="text-decoration:none" class="btn btn-primary radius" title="编辑" href="javascript:;" onclick="edit('资源编辑','/resources/add',this,'600','500')" th:aid="${resources.id}">编辑</a>
                    <a style="text-decoration:none" class="btn btn-danger radius" title="删除" href="javascript:;" onclick="del(this)" th:aid="${resources.id}">删除</a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
<div th:include="fragments/_footer :: _footer"></div>
<script type="text/javascript">

    function add(title, url, w, h) {
        var pid = $("#pid").val();
        layer_show(title, url + "?pid=" + pid, w, h);
    }
    function del(obj) {
        var id = $(obj).attr("aid");
        layer.confirm('资源存在子资源会导致删除失败，确认删除？', function (index) {
            $.post("/resources/delete", {id: id}, function (result) {
                if (result.success) {
                    window.location.reload();
                } else {
                    layer.msg(result.msg, {icon: 2, time: 2000});
                }
            });
        });
    }
    /*资源-编辑*/
    function edit(title, url, obj, w, h) {
        var id = $(obj).attr("aid");
        var pid = $("#pid").val();
        layer_show(title, url + "?id=" + id + "&pid=" + pid, w, h);
    }
</script>
</body>
</html>